// Per Frag ADS Lighting model (Phong shading) - based on: 
//    RealTime Rendering class notes (Celes, W. 2014) 
//    Mathematics for 3D Game Programming and CG, 3th (Lengyel)
//    OpenGL Super Bible 6th (Sellers, Wright, Haemel)
//    OpenGL 4.0 Shading Cookbook (Wolff)

#version 440

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 normal;

uniform mat4 modelView;
uniform mat3 normalMatrix;

layout (std140, binding = 0) uniform TransformBlock{
   mat4 projection;
} transform;

out VS_OUT{
   vec3 ws_coords;
   vec3 vN;   
} vsOut;

void main ()
{
   vsOut.vN = normalize (normalMatrix*normal); // N - normal vector
   vec4 vPosition4 = (modelView)*vec4 (position, 1.0);
   
   vsOut.ws_coords = vPosition4.xyz;


   gl_Position = transform.projection*modelView*vec4 (position, 1.0);
}